import { createRouter, createWebHashHistory } from "vue-router";
import home from "@/view/home/index.vue";
import category from "@/view/category/index.vue";
import layout from "@/view/layout/index.vue";
import login from "@/view/login/login.vue";
import subcategory from "@/view/subCategory/index.vue";
import detail from "@/view/detail/index.vue";
const routes = [
  {
    path: "/",
    component: layout,
    children: [
      {
        path: "", //默认路径
        component: home,
        meta: { breadcrumb: "首页" },
      },

      {
        path: "/category/:id",
        component: category,
      },
      {
        path: "/category/sub/:id",
        component: subcategory,
      },
      {
        path: "/detail/:id",
        component: detail,
      },
    ],
  },

  {
    path: "/login",
    component: login,
  },
];
const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes,
  scrollBehavior() {
    return {
      top: 0,
    };
  },
});
export default router;
